package com.situ.b2c.catalog.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.situ.b2c.catalog.dao.CatalogDao;
import com.situ.b2c.catalog.service.CatalogService;
import com.situ.b2c.pojo.Catalog;
@Service
public class CatalogServiceImpl implements CatalogService{
	@Autowired
	private CatalogDao catalogDao;
	
	@Override
	public List<Catalog> selectAll() {
		return catalogDao.selectAll();
	}
	
	@Override
	public int insert(Catalog catalog) {
		
		return catalogDao.insert(catalog);
	}

	@Override
	public int delete(Long rowId) {
		
		return catalogDao.delete(rowId);
	}

	@Override
	public Catalog selectOneById(Long rowId) {
		
		return catalogDao.selectOneById(rowId);
	}

	@Override
	public int update(Catalog catalog) {
		Long rowId =catalog.getRowId();
		
		Catalog editCata = catalogDao.selectOneById(rowId);
		editCata.setParentId(catalog.getParentId());
		editCata.setCataName(catalog.getCataName());
		editCata.setRankCount(catalog.getRankCount());
		editCata.setActiveFlag(catalog.getActiveFlag());
		editCata.setUpdateBy(catalog.getUpdateBy());
		editCata.setUpdateDate(catalog.getUpdateDate());
		
		
		return catalogDao.update(editCata);
	}
	
	
}
